﻿Imports System
Imports System.IO
Imports System.Runtime.Serialization
Imports System.Runtime.Serialization.Formatters.Binary
<Serializable()> Public Class PointSources
    Implements ICloneable

    Private m_PointSource(-1) As PointSource '点源数组
    Private m_nStack As Integer = 0 '污染源编号，污染源编号只增加，不减少以避免重复。
    ''' <summary>
    ''' 污染源编号
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Property nStack() As Integer
        Get
            Return Me.m_nStack
        End Get
        Set(ByVal value As Integer)
            Me.m_nStack = value
        End Set
    End Property
    ''' <summary>
    ''' 点源数组
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Property PointSource() As PointSource()
        Get
            Return Me.m_PointSource
        End Get
        Set(ByVal value As PointSource())
            Me.m_PointSource = value
        End Set
    End Property
    ''' <summary>
    ''' 删除对应的污染源
    ''' </summary>
    ''' <param name="Index"></param>
    ''' <remarks></remarks>
    Public Sub RemoveFormIndex(ByVal Index As Integer)
        Dim iSelected As Integer = Index
        If iSelected >= 0 Then
            If iSelected <= Me.m_PointSource.Length - 2 Then
                For i As Integer = iSelected To Me.m_PointSource.Length - 2
                    Me.m_PointSource(i) = Me.m_PointSource(i + 1)
                Next
            End If
            ReDim Preserve Me.m_PointSource(Me.m_PointSource.Length - 2)
        End If
    End Sub

    Public Function Clone() As Object Implements System.ICloneable.Clone
        Dim obj As New PointSources
        ReDim obj.m_PointSource(Me.m_PointSource.Length - 1) '点源数组
        For i As Integer = 0 To Me.m_PointSource.Length - 1
            obj.m_PointSource(i) = Me.m_PointSource(i).Clone
        Next
        obj.m_nStack = Me.m_nStack  '污染源编号，污染源编号只增加，不减少以避免重复。
        Return obj
    End Function
End Class
